package com.isnmp.nms.framework.discover.rstype;

import java.util.Iterator;
import java.util.List;
import java.util.Vector;

import com.isnmp.common.snmp.SNMPFactory;
import com.isnmp.nms.framework.discover.DeviceInfo;
import com.isnmp.nms.framework.discover.ResourceInfo;
import com.isnmp.nms.framework.discover.ResourceSearchMothType;

public class GernalTableSearchType extends ResourceSearchMothType {
    /**
     * 
     */
    public List<ResourceInfo> getResoureInfo(DeviceInfo paramDeviceInfo) {
        Vector localVector = new Vector();
        try {
            List localList1 = getOIDStringList();
            List localList2 = SNMPFactory.getSNMPAPI().getAllOIDTableData(paramDeviceInfo.getSnmpTarget(), localList1);
            Iterator localIterator = localList2.iterator();
            while (localIterator.hasNext()) {
                List localList3 = (List) localIterator.next();
                String str1 = (String) localList3.get(0);
                String str2 = (String) localList3.get(1);
                String str3 = (String) localList3.get(2);
                String str4 = (String) localList3.get(3);
                ResourceInfo localResourceInfo = new ResourceInfo();
                localResourceInfo.setLocalDevice(paramDeviceInfo);
                localResourceInfo.setResourceDesc("OID=" + getResourceRSID());
                localResourceInfo.setResourceName(replaceOIDValue(getDisplayNameCode(), str3));
                localResourceInfo.setResourceObjectInfo(str1);
                localResourceInfo.setResourceParam(replaceOIDValue(getParamCode(), str4));
                localResourceInfo.setResourceRSIDValue(str1);
                localResourceInfo.setResourceTypeName(getResoureTypeName());
                localResourceInfo.setResrouceRemarks(Messages.getString("GernalTableSearchType.1") + str2);
                localVector.add(localResourceInfo);
            }
        } catch (Exception localException) {
            localException.printStackTrace();
        }
        return localVector;
    }

    public String getResourceSearchMoth() {
        return Messages.getString("GernalTableSearchType.2");
    }

    private List<String> getOIDStringList() {
        Vector localVector = new Vector();
        String str1 = getOID(getDisplayNameCode());
        String str2 = getOID(getParamCode());
        localVector.add(getResourceRSID());
        localVector.add(str1);
        localVector.add(str2);
        return localVector;
    }

    private String getOID(String paramString) {
        int i = paramString.indexOf("<");
        if (i < 0)
            return "";
        int j = paramString.indexOf(">");
        String str = paramString.substring(i + 1, j);
        return str;
    }

    private String replaceOIDValue(String paramString1, String paramString2) throws Exception {
        int i = paramString1.indexOf("<");
        if (i < 0)
            return paramString1;
        int j = paramString1.indexOf(">");
        String str = paramString1.substring(i + 1, j);
        if (str.length() > 1) {
            StringBuffer localStringBuffer = new StringBuffer(paramString1);
            return localStringBuffer.replace(i, j + 1, paramString2).toString();
        }
        return paramString1;
    }
}